package com.spy.dish.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.spy.dish.mapper.DishIngredientMapper;
import com.spy.dish.domain.DishIngredient;
import com.spy.dish.service.IDishIngredientService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Arrays;

/**
 * 菜品用料Service业务层处理
 *
 * @author zhaoxy
 * @date 2025-11-09
 */
@Service
public class DishIngredientServiceImpl extends ServiceImpl<DishIngredientMapper, DishIngredient> implements IDishIngredientService {
    @Autowired
    private DishIngredientMapper dishIngredientMapper;

    /**
     * 查询菜品用料
     *
     * @param id 菜品用料主键
     * @return 菜品用料
     */
    @Override
    public DishIngredient selectDishIngredientById(Long id) {
        return getById(id);
    }

    /**
     * 查询菜品用料列表
     *
     * @param dishIngredient 菜品用料
     * @return 菜品用料
     */
    @Override
    public List<DishIngredient> selectDishIngredientList(DishIngredient dishIngredient) {
        return dishIngredientMapper.selectDishIngredientList(dishIngredient);
    }

    /**
     * 新增菜品用料
     *
     * @param dishIngredient 菜品用料
     * @return 结果
     */
    @Override
    public int insertDishIngredient(DishIngredient dishIngredient) {
        return save(dishIngredient) ? 1 : 0;
    }

    /**
     * 修改菜品用料
     *
     * @param dishIngredient 菜品用料
     * @return 结果
     */
    @Override
    public int updateDishIngredient(DishIngredient dishIngredient) {
        return updateById(dishIngredient) ? 1 : 0;
    }

    /**
     * 批量删除菜品用料
     *
     * @param ids 需要删除的菜品用料主键
     * @return 结果
     */
    @Override
    public int deleteDishIngredientByIds(Long[] ids) {
        return removeByIds(Arrays.asList(ids)) ? 1 : 0;
    }

    /**
     * 删除菜品用料信息
     *
     * @param id 菜品用料主键
     * @return 结果
     */
    @Override
    public int deleteDishIngredientById(Long id) {
        return removeById(id) ? 1 : 0;
    }
}